finp$="picture.png"
setdisplay(512,256,32,1):paper(0x7f7f7f):ink(0):pen(0):cls
'- opens the image
loadimage(finp$,1):pasteicon(0,0,1)
'-- define cluster
dim clust[8,8]:a$="00,06,08,14,02,12,04,10,08,14,00,06,04,10,02,12"
for y2=0 to 3:for x2=0 to 3:lc=(y2*4)+x2
  clust[x2,y2]=val(mid$(a$,(lc*3)+1,2)):next:next
'---
for y=0 to 255:for x1=0 to 63
  btv=0
  for x2=0 to 7
    x=(x1*8)+x2
    ind=point(x,y)
    b=ind mod 256:ind=int(ind/256)
    g=ind mod 256:ind=int(ind/256)
    r=ind mod 256
    w=int(((b*11)+(r*30)+(g*59))/100)
    patgf=(((clust[x mod 4,y mod 4]+1)*255)/16)
    wpat=0:if w>patgf then:wpat=1:end if
    btv=btv*2:btv=btv+wpat
    ink(0):if wpat<>0 then:ink(0xFFFFFF):end if:dot(x,y)
    next
  next:next
close #1
'- saves the image
grab (1,0,0,512,256):saveimage("_.bmp",1):shell ("convert _.bmp _.png && rm _.bmp")
waitkey


